﻿<%@ Page Language="C#" MasterPageFile="~/Admin/QuanLy.master" AutoEventWireup="true"
    Theme="Default" CodeFile="QuanLySanPham.aspx.cs" Inherits="Admin_QuanLySanPham"
    Title="Quản lý sản phẩm" MaintainScrollPositionOnPostback="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="content_t">
        &nbsp;</div>
    <div id="content">
        <div align="center" id="list">
            <h3>
                Danh sách sản phẩm</h3>
            <asp:GridView SkinID="GridView" ID="gv_SanPham" runat="server" AutoGenerateColumns="False"
                OnRowCommand="gv_SanPham_RowCommand" OnRowDeleting="gv_SanPham_RowDeleting" OnPageIndexChanging="gv_SanPham_PageIndexChanging">
                <Columns>
                    <asp:BoundField DataField="MaSP" HeaderText="Mã sản phẩm">
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TenSP" HeaderText="Tên sản phẩm">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="MoTaChiTiet" HeaderText="Mô tả sản phẩm">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="DonViTinh" HeaderText="Đơn vị tính">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TenLoaiSP" HeaderText="Loại sản phẩm">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="slnhap" Visible="False">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField DataField="slxuat" Visible="False">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Số lượng còn">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# SoLuongCon(float.Parse(Eval("slnhap").ToString()), float.Parse(Eval("slxuat").ToString())) %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:ButtonField CommandName="Sua" Text="Sửa">
                        <ItemStyle VerticalAlign="Middle" />
                    </asp:ButtonField>
                    <asp:CommandField DeleteText="Xóa" ShowDeleteButton="True" />
                </Columns>
            </asp:GridView>
        </div>
        <div align="center" id="form">
            <asp:Table runat="server" SkinID="Table" ID="tblThem" Visible="false">
                <asp:TableHeaderRow SkinID="TableHeaderRow">
                    <asp:TableHeaderCell ColumnSpan="2">THÔNG TIN SẢN PHẨM</asp:TableHeaderCell>
                </asp:TableHeaderRow>
                <asp:TableRow>
                    <asp:TableCell SkinID="TableCell">Tên sản phẩm</asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txtTenSP" CssClass="TextBox" runat="server" Width="170px"></asp:TextBox><asp:RequiredFieldValidator
                            ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTenSP" ErrorMessage="*"></asp:RequiredFieldValidator></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell SkinID="TableCell">Mô tả sản phẩm</asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txtMoTaSP" CssClass="TextBox" runat="server" Width="170px"></asp:TextBox></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell SkinID="TableCell">Đơn vị tính</asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txtDonViTinh" CssClass="TextBox" runat="server" Width="170px"></asp:TextBox><asp:RequiredFieldValidator
                            ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDonViTinh"
                            ErrorMessage="*">
                        </asp:RequiredFieldValidator>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell SkinID="TableCell">Loại sản phẩm</asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="cmbLoaiSP" CssClass="TextBox" runat="server" Width="95px">
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableFooterRow SkinID="TableFooterRow">
                    <asp:TableHeaderCell ColumnSpan="2" HorizontalAlign="Center">
                        <asp:Button ID="btnCapNhat" runat="server" Text="Cập nhật" OnClick="btnCapNhat_Click" />
                        <asp:Button ID="btnHuy" runat="server" Text="Hủy bỏ" OnClick="btnHuy_Click" CausesValidation="False" />
                    </asp:TableHeaderCell>
                </asp:TableFooterRow>
            </asp:Table>
            <asp:Button ID="btnThemSP" runat="server" Text="Thêm sản phẩm" OnClick="btnThemSP_Click"
                CausesValidation="False" />
        </div>
    </div>
    <div id="content_b">
        &nbsp;</div>
</asp:Content>
